<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@ include file="/taglibs.jsp"%>
<script type="text/javascript" charset="UTF-8" src="/js/formValidator.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8" src="/js/formValidatorRegex.js" charset="UTF-8"></script>
<s:actionerror cssClass="errmsg"/>
<s:actionmessage cssClass="errmsg"/>
  <h1>编辑资料 - 批次修改订制商品</h1>
  <div class="batchstep">
    <div class="batchstep-2">
      <span class="step1">Step 1：查寻商品/选取商品</span>
      <span class="onstep2">Step 2：编辑资料</span>
      <span class="step3">Step 3：核对资料/完成编辑</span>
    </div>
  </div>
<script language="javascript">
$().ready( function() {	
	var  r  = "^[0-9]*[0-9][0-9]*$";	
		$("#newsubmit").click(function(){
			if($("#tmpUseDeliveryDay_Y").attr("checked")==true) {
				if($("#tmpDeliveryDay").val().match(r)){
					$("#dataoldornew").val("new");
					$("#oldsubmit").attr("disabled",true); 
					$("#nextsubmit").hide();
					$("#errtable").hide();
					$("#confirmForm").submit();	
				}else{
					alert("订制商品天数必须为正数");
					return false;
				}
			}else{
				$("#tmpDeliveryDay").val("0");
				$("#dataoldornew").val("new");
				$("#oldsubmit").attr("disabled",true); 
				$("#nextsubmit").hide();
				$("#errtable").hide();	
				$("#confirmForm").submit();
			}
			
		});
		
		$("#oldsubmit").click(function() {
			$("#dataoldornew").val("old");
			$("#newsubmit").attr("disabled",true);
			$("#tmpUseDeliveryDay_Y").attr("disabled",true);
			$("#tmpUseDeliveryDay_N").attr("disabled",true);
			$("#tmpDeliveryDay").attr("disabled",true); 
			$("#nextsubmit").hide();
			$("#errtable").hide();	
			$("#confirmForm").submit();
			
		});
		
		$("#mainSubmit").click(function(){
			if ( "" == $("#MultiFile8_F1").val()){
				alert("尚未选择上传档案，请重新选择！");
				return false;
			}
		});
		
});
function applyAll() {
	$(':input[id^="deliveryDay"]').attr("value", $("#tmpDeliveryDay").val());
	if($(":radio[name='tmpUseDeliveryDay']:checked").val()=="Y") {
		$(':radio[id$="_Y"]').attr("checked", true);
		$('[id^="spaninput_"]').show();
		$('[id^="spaninput_hidden_"]').hide();
	} else {
		$(':radio[id$="_N"]').attr("checked", true);
		$('[id^="spaninput_"]').hide();
		$('[id^="spaninput_hidden_"]').show();
	}
}
function hiddenSpan(pId) {
	//alert(pId+","+$("#useDeliveryDay_"+pId+"_Y").attr("checked"));
	if($("#useDeliveryDay_"+pId+"_Y").attr("checked")==true) {
		$("#spaninput_"+pId).show();
		$("#spaninput_hidden_"+pId).hide();
	} else {
		$("#spaninput_"+pId).hide();
		$("#spaninput_hidden_"+pId).show();
	}
}
function hiddenInputSpan() {
	//alert(pId+","+$("#useDeliveryDay_"+pId+"_Y").attr("checked"));
	if($("#tmpUseDeliveryDay_Y").attr("checked")==true) {
		$("#spaninput").show();
		$("#spaninput_hidden").hide();
	} else {
		$("#spaninput").hide();
		$("#spaninput_hidden").show();
	}
}
</script>
  <!-- div class="data-form"> -->
	<img src="/images/ecadmin/bianjiziliaoliucheng.jpg"></img>
  <div class="tipmsg" style="width:53%"><ul><li>系统会将你所选定的商品自动生成Excel报表，请在信息编辑完成后，下载报表。<br/>此阶段具有时效性，请在<Strong>25分钟</Strong>内完成编辑，并上传相关Excel报表</li></ul></div>
  <h2>下载报表</h2>		
		<s:form action="downloadFile.do" method="post" id="confirmForm">
		<table class="tb-edit" style="width:53%;clear:none;">
          <tr>
          	<th>是否使用"订制商品"?</th>
          	<td>
          	<input type="radio" value="Y" name="tmpUseDeliveryDay" id="tmpUseDeliveryDay_Y" onclick="hiddenInputSpan()">是 
          	<input type="radio" checked="checked" value="N" name="tmpUseDeliveryDay" id="tmpUseDeliveryDay_N" onclick="hiddenInputSpan()">否
          	</td>
          </tr>
          <tr>
          	<th>订制商品天数</th>
          	<td>
          	<span id="spaninput" style="display: none;"><input type="text" value="0" size="7" name="tmpDeliveryDay" id="tmpDeliveryDay"></span>
          	<span id="spaninput_hidden">-</span>
          	</td>
          </tr>
          <tr>
          	<th></th>
          	<td>
             <input type="button" id="newsubmit" value="全部套用，下载Excel报表 ">
          	 <input type="hidden" id="dataoldornew" name="dataoldornew">
          	 <c:if test="${!empty event.modifyDate}"><input type="button" id="oldsubmit" value="下载之前上传的报表 "></c:if>
          	</td>
          </tr>
        </table>
        </s:form>
        <br />        
        <h2>上传报表</h2>
        <div class="tipmsg"  style="width:53%"><ul><li>请将核对编辑后的报表上传。</li></ul></div>
		<s:form action="uploadFile.do" method="post" enctype ="multipart/form-data">
	    <table style="width:53%;clear:none;" border="0" align="left" class="tb-data">		
	        <tr>
	          	<td><input id="MultiFile8_F1" class="multi accept-xls" maxlength="1" type="file" name="upload"  accept="xls"/>
	          	<s:submit id="mainSubmit" value="上传Excel报表" /><br><br>
	         	<c:if test="${!empty step2Upload}">
		         	<div style="width:100%;font-size: 15px;" id="errtable" >
		         	上传成功${uploadSuccess}笔<br />
		         	上传失败${uploadErr}笔<br />
			         	<c:if test="${!empty errId}">
			         	上传失败的商品编号（最多显示20笔）:
				         	<c:forEach items="${errId}" var="errId" varStatus="rows_index">
				         	${errId} / 
				         	</c:forEach>	         		
			         	</c:if>
		         	</div>
	         	</c:if>
	         	</td>
	       </tr>
	     </table>
	   </s:form>
		 <br />
	   <s:form action="confirm.do" id="formObj">
	    <table width="560"  border="0"><tr height="40"><td>
	       <c:if test="${empty event.modifyDate}"><a href="changePage.do" class="pstep">﹤回上一步</a></c:if> 
	        <c:if test="${uploadSuccess>0 and uploadErr<=0}">
	        <input type="submit" id="nextsubmit" value="上传完成！下一步﹥"  class="nstep">
	        </c:if>
	      <br />
	      </td></tr></table>
   	 </s:form>

	  <div style="display:none">
		<c:forEach items="${detailMap}" var="map" varStatus="rows_index">       
           <c:if test="${map.value.dataNewMap['useDeliveryDay'] eq 'Y'}">
           <input type="radio" name="detailMap_${map.key}_useDeliveryDay" id="useDeliveryDay_${map.key}_Y" value="Y" onchange="hiddenSpan('${map.key}')" checked="checked">是
           <input type="radio" name="detailMap_${map.key}_useDeliveryDay" id="useDeliveryDay_${map.key}_N" value="N" onchange="hiddenSpan('${map.key}')">否
           </c:if><c:if test="${map.value.dataNewMap['useDeliveryDay'] eq 'N'}">
           <input type="radio" name="detailMap_${map.key}_useDeliveryDay" id="useDeliveryDay_${map.key}_Y" value="Y" onchange="hiddenSpan('${map.key}')">是
           <input type="radio" name="detailMap_${map.key}_useDeliveryDay" id="useDeliveryDay_${map.key}_N" value="N" onchange="hiddenSpan('${map.key}')" checked="checked">否
           </c:if>          
           <c:if test="${map.value.dataNewMap['useDeliveryDay'] eq 'Y'}">
           <span id="spaninput_${map.key}">
           <input type="text" size="7" name="detailMap_${map.key}_deliveryDay" id="deliveryDay_${map.key}" value="${map.value.dataNewMap['deliveryDay']}"/>
           </span><span id="spaninput_hidden_${map.key}" style="display: none;">-</span>
           </c:if>          
           <c:if test="${map.value.dataNewMap['useDeliveryDay'] eq 'N'}">
           <span id="spaninput_${map.key}" style="display: none;">
           <input type="text" size="7" name="detailMap_${map.key}_deliveryDay" id="deliveryDay_${map.key}" value="${map.value.dataNewMap['deliveryDay']}"/>
           </span>
           </c:if>
		</c:forEach>
		</div>

    <!-- </div>  -->